#region File Description
//-----------------------------------------------------------------------------
// PartySaveData.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using System;
using System.Collections.Generic;
using MilwormsGameData;
#endregion

namespace MilwormsGame
{
    /// <summary>
    /// Serializable data for the state of the party.
    /// </summary>
    public class PartySaveData
    {
        /// <summary>
        /// The serializable data for all party members.
        /// </summary>
        public List<PlayerSaveData> players = new List<PlayerSaveData>();

        /// <summary>
        /// The asset names of all party gear.
        /// </summary>
        public List<ContentEntry<Gear>> inventory = new List<ContentEntry<Gear>>();


        #region Initialization


        /// <summary>
        /// Creates a new PartyData object.
        /// </summary>
        public PartySaveData() { }


        /// <summary>
        /// Creates a new PartyData object from the given Party object.
        /// </summary>
        public PartySaveData(Party party)
            : this()
        {
            // check the parameter
            if (party == null)
            {
                throw new ArgumentNullException("party");
            }

            // create and add the serializable player data
            foreach (Player player in party.Players)
            {
                players.Add(new PlayerSaveData(player));
            }

            // add the items
            inventory.AddRange(party.Inventory);
        }


        #endregion
    }
}
